package com.compute;
import com.compute.MyAnnotation.algorithm;
import com.compute.serviceImpl.ManageAlgorithm.TaskManageAlgorithm;
import feign.Logger;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;

import java.lang.reflect.Method;
import java.util.LinkedHashMap;

/**
 * @author 李天航
 */
@SpringBootApplication
@EnableFeignClients
public class TaskManagerApplication {
    @Bean
    public Logger.Level getLog(){//日志对象输出
        return Logger.Level.NONE;
        /*
        NONE:无信息
        BASIC:记录基础信息
        HEADERS:在BASIC的基础上记录一些常用信息
        FULL:全部信息
         */
    }
    @Bean
    public LinkedHashMap<String, Method> putAlgorithmMethods(){
        LinkedHashMap<String, Method> algorithmMap=new LinkedHashMap<>();
        Class<TaskManageAlgorithm> algorithmClass = TaskManageAlgorithm.class;
        Method[] declaredMethods = algorithmClass.getDeclaredMethods();
        for (Method declaredMethod : declaredMethods) {
            if(declaredMethod.isAnnotationPresent(algorithm.class)) {
                System.out.println("已添加活动安排算法："+declaredMethod.getName());
                algorithmMap.put(declaredMethod.getName(),declaredMethod);
            }
        }
        return algorithmMap;
    }
    public static void main(String[] args) {
        SpringApplication.run(TaskManagerApplication.class);
    }
}
